<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

include "../libchart/classes/libchart.php";

header("Content-type: image/png");

$cantidad = $_GET["cantidad"];

$tipo = $_GET["tipo"];
$titulo = $_GET["titulo"];


if($tipo==""){
    $tipo=3;
}


if($tipo==1){
    $chart = new PieChart(500, 300);
}
if($tipo==2){
    $chart = new VerticalBarChart();
}

if($tipo==3){
    
    $chart = new HorizontalBarChart(500,170+30*$cantidad);
}

$dataSet = new XYDataSet();

for ($i=$cantidad;$i>=1;$i--){
    $desc = $_GET[$i];    
    $desc = explode(",",$desc);
    $dataSet->addPoint(new Point($desc[0],$desc[1]));
}

$chart->setDataSet($dataSet);

$chart->setTitle($titulo);
$chart->render();


?>
